﻿<common:LayoutAwarePage
    x:Name="pageRoot"
    x:Class="Education.HubPage"
    DataContext="{Binding DefaultViewModel, RelativeSource={RelativeSource Self}}"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:Education"    
    xmlns:tiles="using:Education.VariableTemplate"
    xmlns:data="using:Education.Data"
    xmlns:common="using:Education.Common"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d">

    <Page.Resources>

        <!--
            Collection of grouped items displayed by this page, bound to a subset
            of the complete item list because items in groups cannot be virtualized
        -->
        <CollectionViewSource
            x:Name="groupedItemsViewSource"
            Source="{Binding Groups}"
            IsSourceGrouped="true"
            ItemsPath="TopItems"
            d:Source="{Binding AllGroups, Source={d:DesignInstance Type=data:HubPageDataSource, IsDesignTimeCreatable=True}}"/>
        
        <tiles:VariableTiles x:Key="MyTemplates"
                             BulletinTemplate="{StaticResource BulletinTemplate}"
                             NormalTemplate="{StaticResource NormalTemplate}"
                             TourTemplate="{StaticResource TourTemplate}">
            
        </tiles:VariableTiles>
        
        <tiles:VariableStyles x:Key="MyStyles"/>

        <!-- TODO: Delete this line if the key AppName is declared in App.xaml -->
        <x:String x:Key="AppName">My Application</x:String>
        <Storyboard x:Name="Arts_Anim_checked">
        	<DoubleAnimationUsingKeyFrames EnableDependentAnimation="True" Storyboard.TargetProperty="(FrameworkElement.Height)" Storyboard.TargetName="stackPanel">
        		<SplineDoubleKeyFrame KeyTime="0:0:0.3" Value="250" KeySpline="0,0.5,0.5,1"/>
        	</DoubleAnimationUsingKeyFrames>
        	<DoubleAnimationUsingKeyFrames EnableDependentAnimation="True" Storyboard.TargetProperty="(FrameworkElement.Height)" Storyboard.TargetName="canvas">
        		<SplineDoubleKeyFrame KeyTime="0:0:0.3" Value="250" KeySpline="0,0.5,0.5,1"/>
        	</DoubleAnimationUsingKeyFrames>
        	
        </Storyboard>
        <Storyboard x:Name="Arts_Anim_UnChecked">
        	<DoubleAnimationUsingKeyFrames EnableDependentAnimation="True" Storyboard.TargetProperty="(FrameworkElement.Height)" Storyboard.TargetName="stackPanel">
        		<SplineDoubleKeyFrame KeyTime="0:0:0.3" Value="0" KeySpline="0,0.5,0.5,1"/>
        	</DoubleAnimationUsingKeyFrames>
        	
        	<DoubleAnimationUsingKeyFrames EnableDependentAnimation="True" Storyboard.TargetProperty="(FrameworkElement.Height)" Storyboard.TargetName="canvas">
        		<SplineDoubleKeyFrame KeyTime="0:0:0.3" Value="0" KeySpline="0,0.5,0.5,1"/>
        	</DoubleAnimationUsingKeyFrames>
        </Storyboard>
        <Storyboard x:Name="Science_Checked">
        	<DoubleAnimationUsingKeyFrames EnableDependentAnimation="True" Storyboard.TargetProperty="(FrameworkElement.Height)" Storyboard.TargetName="stackPanel1">
        		<SplineDoubleKeyFrame KeyTime="0:0:0.3" Value="250" KeySpline="0,0.5,0.5,1"/>
        	</DoubleAnimationUsingKeyFrames>
        	<DoubleAnimationUsingKeyFrames EnableDependentAnimation="True" Storyboard.TargetProperty="(FrameworkElement.Height)" Storyboard.TargetName="canvas_Copy">
        		<SplineDoubleKeyFrame KeyTime="0:0:0.3" Value="250" KeySpline="0,0.5,0.5,1"/>
        	</DoubleAnimationUsingKeyFrames>
        	
        </Storyboard>
        <Storyboard x:Name="Science_Unchecked">
        	<DoubleAnimationUsingKeyFrames EnableDependentAnimation="True" Storyboard.TargetProperty="(FrameworkElement.Height)" Storyboard.TargetName="stackPanel1">
        		<EasingDoubleKeyFrame KeyTime="0:0:0.3" Value="0"/>
        	</DoubleAnimationUsingKeyFrames>
        	
        	<DoubleAnimationUsingKeyFrames EnableDependentAnimation="True" Storyboard.TargetProperty="(FrameworkElement.Height)" Storyboard.TargetName="canvas_Copy">
        		<SplineDoubleKeyFrame KeyTime="0:0:0.3" Value="0" KeySpline="0,0.5,0.5,1"/>
        	</DoubleAnimationUsingKeyFrames>
        </Storyboard>
        <Storyboard x:Name="Masters_Checked">
        	
        	<DoubleAnimationUsingKeyFrames EnableDependentAnimation="True" Storyboard.TargetProperty="(FrameworkElement.Height)" Storyboard.TargetName="stackPanel2">
        		<EasingDoubleKeyFrame KeyTime="0:0:0.3" Value="250"/>
        	</DoubleAnimationUsingKeyFrames>
        	<DoubleAnimationUsingKeyFrames EnableDependentAnimation="True" Storyboard.TargetProperty="(FrameworkElement.Height)" Storyboard.TargetName="canvas_Copy1">
        		<SplineDoubleKeyFrame KeyTime="0" Value="250"/>
        		<SplineDoubleKeyFrame KeyTime="0:0:0.3" Value="250" KeySpline="0,0.5,0.5,1"/>
        	</DoubleAnimationUsingKeyFrames>
        </Storyboard>
        <Storyboard x:Name="Masters_Unchecked">
        	<DoubleAnimationUsingKeyFrames EnableDependentAnimation="True" Storyboard.TargetProperty="(FrameworkElement.Height)" Storyboard.TargetName="stackPanel2">
        		<EasingDoubleKeyFrame KeyTime="0:0:0.3" Value="0"/>
        	</DoubleAnimationUsingKeyFrames>
        	
        	<DoubleAnimationUsingKeyFrames EnableDependentAnimation="True" Storyboard.TargetProperty="(FrameworkElement.Height)" Storyboard.TargetName="canvas_Copy1">
        		<SplineDoubleKeyFrame KeyTime="0:0:0.3" Value="0" KeySpline="0,0.5,0.5,1"/>
        	</DoubleAnimationUsingKeyFrames>
        </Storyboard>
    </Page.Resources>

    <!--
        This grid acts as a root panel for the page that defines two rows:
        * Row 0 contains the back button and page title
        * Row 1 contains the rest of the page layout
    -->
    <Grid Style="{StaticResource LayoutRootStyle}" Background="White">
        <Grid.RowDefinitions>
            <RowDefinition Height="140"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <!-- Horizontal scrolling grid used in most view states -->
        
        <ScrollViewer x:Name="MainScroll"  Grid.RowSpan="2" Style="{StaticResource HorizontalScrollViewerStyle}">
            <StackPanel Orientation="Horizontal">
                <StackPanel x:Name="FirstStack" Margin="120,150,0,0" VerticalAlignment="Top">
                    <TextBlock Text="programs offered" Margin="3,-7,10,10" Style="{StaticResource GroupHeaderTextStyle}"  Foreground="Black"/>


                    <RadioButton x:Name="BAarts" Content="bachelor of arts (honours)" Style="{StaticResource ProgramsRadioBtnStyle}" GroupName="Arts" Checked="RadioButton_Checked_1" Unchecked="RadioButton_Unchecked_1" Margin="0,10,0,2" Background="#FFff5d5d"/>
                    <Canvas x:Name="canvas" Height="250" Width="400" Margin="0,2,0,4" Visibility="Visible">
                    	<StackPanel x:Name="stackPanel" Width="400" Height="250" Background="Black">
                            <Button Content="english literature" Height="40" Style="{StaticResource SubProgramsBtnStyle}" HorizontalAlignment="Stretch" FontSize="14.667" Background="#B3B6B6B6" Click="ELit_Clicked" Tag="#FFff5d5d"/>
                            <Button Content="anthropology" Height="40" Style="{StaticResource SubProgramsBtnStyle}" HorizontalAlignment="Stretch" FontSize="14.667" Tag="#FFff5d5d"/>
                            <Button Content="history" Height="40" Style="{StaticResource SubProgramsBtnStyle}" HorizontalAlignment="Stretch" FontSize="14.667" Tag="#FFff5d5d"/>
                            <Button Content="philosophy" Height="40" Style="{StaticResource SubProgramsBtnStyle}" HorizontalAlignment="Stretch" FontSize="14.667" Tag="#FFff5d5d"/>
                            <Button Content="music" Height="40" Style="{StaticResource SubProgramsBtnStyle}" HorizontalAlignment="Stretch" FontSize="14.667" Tag="#FFff5d5d"/>
                            <Button Content="fine arts" Height="40" Style="{StaticResource SubProgramsBtnStyle}" HorizontalAlignment="Stretch" FontSize="14.667" Tag="#FFff5d5d"/>
                    	</StackPanel>
                    </Canvas>
                    <RadioButton x:Name="BAScience" Content="bachelor of science (honours)" Style="{StaticResource ProgramsRadioBtnStyle}" GroupName="Arts" Checked="ScienceChecked" Unchecked="ScienceUnchecked" Margin="0,2" Background="#FFff5d5d"/>
                    <Canvas x:Name="canvas_Copy" Height="0" Width="400" Margin="0,2,0,4">
                    	<StackPanel x:Name="stackPanel1" Width="400" Height="0" Background="Black">
                            <Button Content="english literature" Height="40" Style="{StaticResource SubProgramsBtnStyle}" HorizontalAlignment="Stretch" FontSize="14.667" Background="#B3B6B6B6" Tag="#FFff5d5d"/>
                            <Button Content="anthropology" Height="40" Style="{StaticResource SubProgramsBtnStyle}" HorizontalAlignment="Stretch" FontSize="14.667" Tag="#FFff5d5d"/>
                            <Button Content="history" Height="40" Style="{StaticResource SubProgramsBtnStyle}" HorizontalAlignment="Stretch" FontSize="14.667" Tag="#FFff5d5d"/>
                            <Button Content="philosophy" Height="40" Style="{StaticResource SubProgramsBtnStyle}" HorizontalAlignment="Stretch" FontSize="14.667" Tag="#FFff5d5d"/>
                            <Button Content="music" Height="40" Style="{StaticResource SubProgramsBtnStyle}" HorizontalAlignment="Stretch" FontSize="14.667" Tag="#FFff5d5d"/>
                            <Button Content="fine arts" Height="40" Style="{StaticResource SubProgramsBtnStyle}" HorizontalAlignment="Stretch" FontSize="14.667" Tag="#FFff5d5d"/>
                    	</StackPanel>
                    </Canvas>
                    <RadioButton x:Name="BAMasters" Content="masters programs (honours)" Style="{StaticResource ProgramsRadioBtnStyle}"  GroupName="Arts" Checked="MastersChecked" Unchecked="MastersUnchecked" Margin="0,2" Background="#FFff5d5d"/>
                    <Canvas x:Name="canvas_Copy1" Height="0" Width="400" Margin="0,4">
                    	<StackPanel x:Name="stackPanel2" Width="400" Height="0" Background="Black">
                            <Button Content="english literature" Height="40" Style="{StaticResource SubProgramsBtnStyle}" HorizontalAlignment="Stretch" FontSize="14.667" Background="#B3B6B6B6" Tag="#FFff5d5d"/>
                            <Button Content="anthropology" Height="40" Style="{StaticResource SubProgramsBtnStyle}" HorizontalAlignment="Stretch" FontSize="14.667" Tag="#FFff5d5d"/>
                            <Button Content="history" Height="40" Style="{StaticResource SubProgramsBtnStyle}" HorizontalAlignment="Stretch" FontSize="14.667" Tag="#FFff5d5d"/>
                            <Button Content="philosophy" Height="40" Style="{StaticResource SubProgramsBtnStyle}" HorizontalAlignment="Stretch" FontSize="14.667" Tag="#FFff5d5d"/>
                            <Button Content="music" Height="40" Style="{StaticResource SubProgramsBtnStyle}" HorizontalAlignment="Stretch" FontSize="14.667" Tag="#FFff5d5d"/>
                            <Button Content="fine arts" Height="40" Style="{StaticResource SubProgramsBtnStyle}" HorizontalAlignment="Stretch" FontSize="14.667" Tag="#FFff5d5d"/>
                    	</StackPanel>
                    </Canvas>
                </StackPanel>
                <!--itemGridView-->
                <!--<tiles:VariableTileControl-->
                <tiles:VariableTileControl
            x:Name="itemGridView"
            AutomationProperties.AutomationId="itemGridView"
            AutomationProperties.Name="Grouped Items"
            Grid.RowSpan="2"
            Padding="80,150,40,46"
            ItemsSource="{Binding Source={StaticResource groupedItemsViewSource}}"
            ItemTemplateSelector="{StaticResource MyTemplates}"
            ItemContainerStyleSelector="{StaticResource MyStyles}"
            SelectionMode="None"
            IsSwipeEnabled="false">

                <tiles:VariableTileControl.ItemsPanel>
                    <ItemsPanelTemplate>
                        <VirtualizingStackPanel Orientation="Horizontal" Margin="0,0,80,0"/>
                    </ItemsPanelTemplate>
                </tiles:VariableTileControl.ItemsPanel>
                <tiles:VariableTileControl.GroupStyle>
                    <GroupStyle>
                        <GroupStyle.HeaderTemplate>
                            <DataTemplate>
                                <Grid Margin="1,0,0,6">
                                        <Button Foreground="Black" Click="BulletinBoard_Clicked" Tag="{Binding UniqueId}"
                                    AutomationProperties.Name="Group Title"
                                    Style="{StaticResource TextPrimaryButtonStyle}">
                                        <StackPanel Orientation="Horizontal">
                                            <TextBlock Text="{Binding Title}" Margin="3,-7,10,10" Style="{StaticResource GroupHeaderTextStyle}" />
                                            <TextBlock Text="{StaticResource ChevronGlyph}" FontFamily="Segoe UI Symbol" Margin="0,-7,0,10" Style="{StaticResource GroupHeaderTextStyle}"/>
                                        </StackPanel>
                                    </Button>
                                </Grid>
                            </DataTemplate>
                        </GroupStyle.HeaderTemplate>
                        <GroupStyle.Panel>
                            <ItemsPanelTemplate>
                                <VariableSizedWrapGrid ItemHeight="10" ItemWidth="10" Orientation="Vertical" Margin="0,0,80,0"/>
                            </ItemsPanelTemplate>
                        </GroupStyle.Panel>
                    </GroupStyle>
                </tiles:VariableTileControl.GroupStyle>
            </tiles:VariableTileControl>
            </StackPanel>
        </ScrollViewer>
       

        <!-- Vertical scrolling list only used when snapped -->
        <ListView
            x:Name="itemListView"
            AutomationProperties.AutomationId="ItemListView"
            AutomationProperties.Name="Grouped Items"
            Grid.Row="1"
            Visibility="Collapsed"
            Margin="0,10,0,0"
            Padding="10,0,0,60"
            ItemsSource="{Binding Source={StaticResource groupedItemsViewSource}}"
            ItemTemplate="{StaticResource Standard80ItemTemplate}"
            SelectionMode="None"
            IsSwipeEnabled="false">

            <ListView.GroupStyle>
                <GroupStyle>
                    <GroupStyle.HeaderTemplate>
                        <DataTemplate>
                            <Grid Margin="7,7,0,0">
                                <Button Foreground="Black" Click="BulletinBoard_Clicked" Tag="{Binding UniqueId}"
                                    AutomationProperties.Name="Group Title"
                                    Style="{StaticResource TextPrimaryButtonStyle}">
                                    <StackPanel Orientation="Horizontal">
                                        <TextBlock Text="{Binding Title}" Margin="3,-7,10,10" Style="{StaticResource GroupHeaderTextStyle}" />
                                        <TextBlock Text="{StaticResource ChevronGlyph}" FontFamily="Segoe UI Symbol" Margin="0,-7,0,10" Style="{StaticResource GroupHeaderTextStyle}"/>
                                    </StackPanel>
                                </Button>
                            </Grid>
                        </DataTemplate>
                    </GroupStyle.HeaderTemplate>
                </GroupStyle>
            </ListView.GroupStyle>
        </ListView>

        <!-- Back button and page title -->
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition/>
            </Grid.ColumnDefinitions>
            <Rectangle Fill="Black" Grid.ColumnSpan="2" />
            <Button x:Name="backButton" Click="GoBack" IsEnabled="{Binding Frame.CanGoBack, ElementName=pageRoot}" Style="{StaticResource BackButtonStyle}" Foreground="White"/>
            <!--<TextBlock x:Name="pageTitle" Text="{StaticResource AppName}" Grid.Column="1" IsHitTestVisible="false" Style="{StaticResource PageHeaderTextStyle}" Foreground="#DEFFFFFF"/>-->
            <Image Source="/Assets/AppLogo.png" Grid.Column="1" HorizontalAlignment="Left" VerticalAlignment="Center" Height="80"/>
        </Grid>

        <VisualStateManager.VisualStateGroups>

            <!-- Visual states reflect the application's view state -->
            <VisualStateGroup x:Name="ApplicationViewStates">
                <VisualState x:Name="FullScreenLandscape"/>
                <VisualState x:Name="Filled"/>

                <!-- The entire page respects the narrower 100-pixel margin convention for portrait -->
                <VisualState x:Name="FullScreenPortrait">
                    <Storyboard>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="backButton" Storyboard.TargetProperty="Style">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource PortraitBackButtonStyle}"/>
                        </ObjectAnimationUsingKeyFrames>

                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="itemGridView" Storyboard.TargetProperty="Padding">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="80,150,10,56"/>
                        </ObjectAnimationUsingKeyFrames>

                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="FirstStack" Storyboard.TargetProperty="Margin">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="110,150,10,56"/>
                        </ObjectAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualState>

                <!--
                    The back button and title have different styles when snapped, and the list representation is substituted
                    for the grid displayed in all other view states
                -->
                <VisualState x:Name="Snapped">
                    <Storyboard>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="backButton" Storyboard.TargetProperty="Style">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource SnappedBackButtonStyle}"/>
                        </ObjectAnimationUsingKeyFrames>
                    
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="itemListView" Storyboard.TargetProperty="Visibility">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="Visible"/>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="MainScroll" Storyboard.TargetProperty="Visibility">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed"/>
                        </ObjectAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualState>
            </VisualStateGroup>
        </VisualStateManager.VisualStateGroups>
    </Grid>
</common:LayoutAwarePage>
